#!/usr/bin/env groovy
import static java.lang.System.*
import static javax.swing.JOptionPane.*
import javax.swing.*

File.metaClass.define{
    isDotFile{
        delegate.name.startsWith(".")
    }
    
    isEmpty{ ignoreDotFile = true ->
        if( delegate.file ){
            return delegate.size() == 0
        } else {
            return delegate.listFiles().findAll{
                !(ignoreDotFile && it.isDotFile())
            }.size() == 0
        }
    }
}

def jEdit = Class.forName("org.gjt.sp.jedit.jEdit")
def fileChooser = new JFileChooser(getProperty("user.home"))
fileChooser.fileSelectionMode = JFileChooser.DIRECTORIES_ONLY
if (fileChooser.showOpenDialog() != JFileChooser.APPROVE_OPTION)
    return;

fileChooser.selectedFile.eachDirRecurse{
    if( !it.path.contains(File.separator + ".") && it.empty ){
        println it.path
    }
}
